﻿/* @function  JsonSort 对json排序
   @param  json     用来排序的json
   @param  key      排序的键值*/
function JsonSort(json, key) {
   for (var j = 1, jl = json.length; j < jl; j++) {
        var temp = json[j],
            val = temp[key],
            i = j - 1;
        while (i >= 0 && parseFloat(json[i][key])>parseFloat((val))){
            json[i + 1] = json[i];
            i = i - 1;
        }
        json[i + 1] = temp;

   }
 
    return json;
}
function transSpecialChar(theString) {

    if (theString != "" || theString != 'undefined' || theString != 'null') {
     
        theString = theString.replace(">","&gt;");
        theString = theString.replace("<","&lt;");
        theString = theString.replace(" ","&nbsp;");
        theString = theString.replace("\"","&quot;");
        theString = theString.replace("\'","&#39;");
        theString = theString.replace("\\","\\\\");//对斜线的转义  
        theString = theString.replace("\n","\\n");
        theString = theString.replace("\r","\\r");
    }
    return theString;
}